import React, { createContext, ReactNode, useContext, useState } from 'react';

export type UserMode = 'enterprise' | 'personal' | null;

interface ModeContextType {
  userMode: UserMode;
  setUserMode: (mode: UserMode) => void;
  isEnterpriseMode: boolean;
  isPersonalMode: boolean;
}

const ModeContext = createContext<ModeContextType | undefined>(undefined);

export function ModeProvider({ children }: { children: ReactNode }) {
  const [userMode, setUserMode] = useState<UserMode>(null);

  const isEnterpriseMode = userMode === 'enterprise';
  const isPersonalMode = userMode === 'personal';

  return (
    <ModeContext.Provider
      value={{
        userMode,
        setUserMode,
        isEnterpriseMode,
        isPersonalMode,
      }}
    >
      {children}
    </ModeContext.Provider>
  );
}

export function useMode() {
  const context = useContext(ModeContext);
  if (context === undefined) {
    throw new Error('useMode must be used within a ModeProvider');
  }
  return context;
} 